package com.yonxao.demo.crud.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.yonxao.demo.crud.annotation.valid.Save;
import com.yonxao.demo.crud.annotation.valid.Update;
import com.yonxao.demo.crud.entity.enums.BooleanEnum;
import com.yonxao.demo.crud.entity.enums.GradeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable;

/**
 * 学生 实体类
 *
 * @author xiaosaguo
 * @date 2021/3/16
 */
@ApiModel("学生")
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
public class Student implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("学号")
    @Null(groups = Save.class)
    @NotNull(groups = Update.class)
    @Range(min = 1, groups = Update.class)
    @TableId
    private Long id;

    @ApiModelProperty("姓名")
    @Length(min = 1, max = 4, groups = {Save.class, Update.class})
    @NotBlank(groups = Save.class)
    private String name;

    @ApiModelProperty("性别")
    @NotNull(message = "需要在取值范围[0, 1]中", groups = {Save.class, Update.class})
    private BooleanEnum sex;

    @ApiModelProperty("年级")
    @NotNull(message = "需要在取值范围[1, 2, 3, 4, 5, 6]中", groups = {Save.class, Update.class})
    private GradeEnum grade;

    @ApiModelProperty("年龄")
    @Range(min = 1, max = 120, groups = {Save.class, Update.class})
    private Byte age;
}
